import request from '../../util/axios'

// 获取门类树-全局
export const getCategoryTree = (labelCode, isNotAjJnNode) => request({
  url: `/yuyi-category-boot/api/metadata/categoryNode/allTree?labelCode=${labelCode}&isNotAjJnNode=${isNotAjJnNode || false}`
})

// 获取门类树-当前登录用户
export const getSelfCategoryTree = (labelCode, isNotAjJnNode) => request({
  url: `/yuyi-category-boot/api/metadata/categoryNode/userTree?labelCode=${labelCode}&isNotAjJnNode=${isNotAjJnNode || false}`
})

// 获取用户门类树-左侧全局
export const getCategoryAllTree = (data) => request({
  url: `/yuyi-category-boot/api/metadata/categoryNode/userTree?labelCode=${data}`
})

// 查询表业务字段
export const getBusinessDic = (data) => request({
  url: `/yuyi-category-boot/api/metadata/categoryTableColumn/biz?idTable=${data}`
})

// 获取用户门类id
export const getUserCategoryId = (userId) => request({
  url: `/yuyi-user-boot/api/sys/sysCategoryScope/userId/${userId}`
})

// 用户门类数据权限key
export const getUserCategoryKeys = (userId) => request({
  url: `/yuyi-user-boot/api/sys/sysCategoryScope/dataId/${userId}/user`
})
// 角色门类数据权限key
export const getRoleCategoryKeys = (roleId) => request({
  url: `/yuyi-user-boot/api/sys/sysCategoryScope/dataId/${roleId}/role`
})
// 分页查询门类信息
export const getCategoryList = (data) => request({
  url: '/yuyi-category-boot/api/metadata/category/paging',
  method: 'post',
  data: data
})
// 根据门类id获取实体门类表
export const getEntityCategory = (idCategory) => {
  return request({
    url: `/yuyi-category-boot/api/metadata/categoryTable/idCategory/${idCategory}`
  })
}
// 分页查询实体门类表字段
export const getEntityCategoryList = (data) => request({
  url: '/yuyi-category-boot/api/metadata/categoryTableColumn/paging',
  method: 'post',
  data: data
})
// 新增实体门类表字段
export const addEntityCategoryList = (data) => request({
  url: '/yuyi-category-boot/api/metadata/categoryTableColumn',
  method: 'post',
  data: data
})
// 编辑实体门类表字段
export const editEntityCategoryList = (data) => request({
  url: '/yuyi-category-boot/api/metadata/categoryTableColumn',
  method: 'put',
  data: data
})
// 删除实体门类表字段
export const delEntityCategoryList = (data) => request({
  url: '/yuyi-category-boot/api/metadata/categoryTableColumn',
  method: 'delete',
  data: data
})
// 删除实体门类表
export const delCategoryList = (data) => request({
  url: '/yuyi-category-boot/api/metadata/category',
  method: 'delete',
  data: data
})

// 元数据 --- 分页查询字段信息
export const getMetadataList = (data) => request({
  url: '/yuyi-category-boot/api/metadata/column/paging',
  method: 'post',
  data: data
})

// 获取门类信息
export const getCategoryInfo = (id) => request({
  url: `/yuyi-category-boot/api/metadata/category/${id}`
})
// 查询门类结构信息
export const queryCategoryInfo = (id) => request({
  url: `/yuyi-category-boot/api/metadata/category/${id}/child`,
  method: 'post'
})
// 类似创建门类信息
export const addCategoryInfo = (data) => request({
  url: '/yuyi-category-boot/api/metadata/category/copy',
  method: 'post',
  data: data
})
// 修改门类信息
export const editCategoryInfo = (data) => request({
  url: '/yuyi-category-boot/api/metadata/category',
  method: 'put',
  data: data
})

// 获取所有门类标签
export const getCategoryLabelAll = () => request({
  url: '/yuyi-category-boot/api/metadata/categoryLabel/all'
})
// 获取所有门类
export const getCategoryAll = () => request({
  url: '/yuyi-category-boot/api/metadata/category/all'
})

// 更新门类树
export const editCategoryTree = (data) => request({
  url: '/yuyi-category-boot/api/metadata/categoryLabel/tree',
  method: 'put',
  data: data
})

// 根据id_table和md_code获取实体门类表字段
export const getCategoryDicTypeName = (idTable, mdCode) => request({
  url: `/yuyi-category-boot/api/metadata/categoryTableColumn/idTable/${idTable}/mdCode/${mdCode}`
})
